<include file="Index/header" />

<div class="container">
	<form action="?m=home&c=user&a=login" method="post" onsubmit="return checkForm()"
		style="width: 30%; margin: 60px auto;">
		<div class="form-group">
			<label for="u_name">用户名</label>
			<input type="text" class="form-control" placeholder="用户名" name="u_name" id="uname">
		</div>
		<div class="form-group">
			<label for="u_pwd">密码</label>
			<input type="password" class="form-control" placeholder="密码" name="u_pwd" id="upwd">
		</div>
		<div class="form-group">
			<label for="validation">验证码</label>
			<input type="text" class="form-control" placeholder="验证码" name="validation" id="validation">
			<img src="{$address}/image_validation.php" alt="" id="code_img">
			<a href="#" id="change" onclick="getValidation('{$address}')">看不清楚，换一张</a><br>
		</div>
		<div class="checkbox">
			<label>
				<input type="checkbox" name="auto_login" id="auto_login" checked="checked"> 记住我
			</label>
		</div>
		<div class="register">
			<label>
				<a href="?m=home&c=user&a=register"
					class="text-muted glyphicon glyphicon-arrow-right">还没有账户，赶紧注册一个吧！</a>
			</label>
		</div>
		<button type="submit" class="btn btn-primary btn-lg btn-block">登 陆</button>
	</form>
	<!--错误信息提示-->
	<notempty name='error'>
		<div class='alert alert-danger' style="margin-right:60%">
			<span style='color:red'>错误信息:</span>
			<foreach name='error' item='error'>
				<li>{$error}</li>
			</foreach>
		</div>
	</notempty>
</div>

<script type="text/javascript">
	function getValidation(address) {
		var img = document.getElementById("code_img");
		//将img的src属性重新设置
		img.src = address + "/image_validation.php?t=" + new Date().getTime(); //获取时间防止图片缓存
		return false;//防止页面跳转
	}
	//进行初步非空检测
	function checkForm() {
		var v = document.getElementById("validation").value;
		var u = document.getElementById("uname").value;
		var p = document.getElementById("upwd").value;
		if (v == "") {
			alert("请输入验证码！！");
			return false;
		}
		else if (u == "") {
			alert("用户名不能为空！！");
			return false;
		}
		else if (p == "") {
			alert("密码未填写！！");
			return false;
		}
		return true;
	}
</script>

<include file="Index/footer" />